<template>
  <div>
    <button @click="show = !show">显示/隐藏</button>
    <transition name="slide">
      <div v-if="show" class="dv">滑动进入效果</div>
    </transition>
  </div>
</template>

<script setup>
import { ref } from "vue";
let show = ref(false);
</script>

<style>
.dv {
  margin-top: 20px;
  padding: 30px;
  width: 200px;
  background-color: burlywood;
  color: cadetblue;
}
.slide-enter-active{
    transition: all 5s ease-out;
}
.slide-leave-active{
    transition: all 5s ease-in;
}
.slide-enter-from{
    transform: translateX(-50px);
    opacity: 0;
}
.slide-leave-to{
    transform: translateX(-50px);
    opacity: 0;
}
</style>